<?php 
	include "../service/util/authenticateSession.php";
	$url = ($_SERVER['REQUEST_URI']);
	if (!preg_match('/^id=[1-9]{1,}[0-1]*$/', substr($url, strrpos($url, "?") + 1, strlen($url))))
		echo "<script>window.location.href= 'index.php';</script>";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
	<title>Chi tiết tài khoản người dùng</title>
	<?php 
		include("import.php");
		include_once("../service/userService.php");
		
		$userId = $_GET["id"];
		$result = findUserDetail($userId);
		if (ConnectionManager::getInstance()->getNumRows() == 0)
            echo "<script>window.location.href='index.php';</script>";
	?>
</head>
<body>
<?php include "header.php"; ?>
<form id="form">
<!-- Container -->
<div id="container">
	<div class="shell">
		<div id="main">
			<div class="cl">&nbsp;</div>
			<!-- Content -->
			<div id="content">        
				<!-- Box -->
				<div class="box">
					<!-- Box Head -->
					<div class="box-head">
						<h2>Thông Tin Tài Khoản</h2>
					</div>
					<!-- End Box Head -->
						<!-- Form -->
						<div class="form">
                        	<?php
								$row = ConnectionManager::getInstance()->fetch($result);
                            ?>
                            <p>
                                <label>Tên Đăng Nhập</label>
                                <input type="text" class="field size1" value="<?php echo $row["USER_NAME"]; ?>" disabled="disabled"/>
                            </p>
                            <p>
                                <label>Họ và Tên</label>
                                <input type="text" class="field size1" value="<?php echo $row["USER_FULLNAME"]; ?>" disabled="disabled"/>
                            </p>
                            <p>
                                <label>Loại Tài Khoản</label>
                                <select class="field size1" disabled="disabled">
                                	<?php
                                    	if($row["USER_TYPE"] == 1) {
									?>
	                                    <option value="" selected="selected">Admin</option>
                                    <?php
										} else {                                    
									?>    
	                                    <option value="" selected="selected">User</option>
                                    <?php
										}
                                    ?>
                                </select>
                            </p>
                            <p>
                                <label>Ngày Sinh</label>
                                <input type="text" class="field size1" value="<?php echo date_format(date_create($row["USER_DOB"]), "d/m/Y"); ?>" disabled="disabled"/>
                            </p>	
                            <p>
                                <label>Địa Chỉ</label>
                                <input type="text" class="field size1" value="<?php echo $row["USER_ADDRESS"]; ?>" disabled="disabled"/>
                            </p>
                            <p>
                                <label>Số Điện Thoại</label>
                                <input type="text" class="field size1" value="<?php echo $row["USER_PHONENUMBER"]; ?>" disabled="disabled"/>
                            </p>
                            <p>
                                <label>Ngày Tạo</label>
                                <input type="text" class="field size1" value="<?php echo date_format(date_create($row["USER_CREATEDATE"]), "d/m/Y"); ?>" disabled="disabled"/>
                            </p>						
						</div>
						<!-- End Form -->
						<!-- Form Buttons -->
						<div class="buttons">
                            <input type="button" class="button" value="Trở Về" onclick="window.location = 'user.php';" />
						</div>
						<!-- End Form Buttons -->
				</div>
				<!-- End Box -->
			</div>
			<!-- End Content -->
			<div class="cl">&nbsp;</div>			
		</div>
		<!-- Main -->
	</div>
</div>
<!-- End Container -->
</form>
<?php
	include "footer.php";
	ConnectionManager::getInstance()->closeConnection();
?>
</body>
</html>
